<template>
  <div>
    <div ref="left" style="height: 400px;" />
  </div>
</template>
<script>
import * as echarts from 'echarts/core'
import {
  DatasetComponent,
  TitleComponent,
  TooltipComponent,
  GridComponent,
  LegendComponent
} from 'echarts/components'
import { BarChart } from 'echarts/charts'
import { CanvasRenderer } from 'echarts/renderers'

echarts.use([
  DatasetComponent,
  TitleComponent,
  TooltipComponent,
  GridComponent,
  LegendComponent,
  BarChart,
  CanvasRenderer
])

export default {
  mounted() {
    var chartDom = this.$refs.left
    var myChart = echarts.init(chartDom)
    var option

    option = {
      title: {
        text: '价格数量分布',
        textStyle: {
          color: '#000'
        }
      },
      legend: {},
      tooltip: {},
      dataset: {
        source: [
          ['product', '公寓', '楼房', '酒店'],
          ['2018', 43.3, 85.8, 93.7],
          ['2019', 83.1, 73.4, 55.1],
          ['2021', 86.4, 65.2, 82.5],
          ['2020', 72.4, 53.9, 39.1],
          ['2022', 72.4, 53.9, 39.1]
        ]
      },
      xAxis: { type: 'category' },
      yAxis: {},
      //   series: [{ type: 'bar', barWidth: 20 }, { type: 'bar', barWidth: 20 }, { type: 'bar', barWidth: 20 }]
      series: [{ type: 'bar', barWidth: 25 }, { type: 'bar', barWidth: 25 }, { type: 'bar', barWidth: 25 }]
    }

    option && myChart.setOption(option)
  }
}
</script>
<style scoped>
/* #radar{
      height: 400px;
  } */
</style>

